from datetime import datetime

from DjangoUeditor.models import UEditorField
from django.db import models

# Create your models here.


class TextModel(models.Model):
    #标题 发布时间 文章 阅读量 点赞量
    id = models.IntegerField(primary_key=True, auto_created=True,default=1)
    pub_time = models.DateTimeField(default=datetime.now)
    title = models.CharField(max_length=30)
    Content = UEditorField(u'内容	', width=600, height=300, toolbars="full", imagePath="", filePath="",
                           upload_settings={"imageMaxSize": 1204000},
                           settings={}, command=None, blank=True)
    read_num = models.IntegerField(default=0)
    like_num = models.IntegerField(default=0)

    def __str__(self):
        return "文章"


class CommentModel(models.Model):
    text_id = models.ForeignKey('TextModel', on_delete=models.CASCADE)
    comment_content = models.TextField(max_length=500)
    comment_time = models.DateTimeField(default=datetime.now)
    author = models.CharField(default='Administator', max_length=50)
    comment_like = models.IntegerField(default=0)

    def __str__(self):
        return "评论"

